From golang AS build
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY go.mod  /home
COPY main.go /home
RUN go env -w GO111MODULE=on;go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct;cd /home ;go mod tidy; go build /home/main.go
From golang AS prod
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY --from=build /home/main .
EXPOSE 8080
ENTRYPOINT ["./main"]
